package net.jiastudy.core.common;

public enum LogicalOperator {

	eq("=","等于"), ne("<>", "不等于"), lt("<","小于"), gt(">", "大于"), le("<=", "小于等于"), ge(">=", "大于等于"), in("in", "包含"), notIn("not in","不包含");
	private String desc;
	private String operator;

	LogicalOperator(String operator, String desc) {
		this.desc = desc;
		this.operator = operator;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getOperator() {
		return operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}

	public static LogicalOperator descOf(String desc) {
		for (LogicalOperator type : values()) {
			if (type.desc.equals(desc)) {
				return type;
			}
		}
		throw new IllegalArgumentException("Invalid LogicalOperator name: " + desc);
	}

	public static LogicalOperator operatorOf(String operator) {
		for (LogicalOperator type : values()) {
			if (type.operator.equals(operator)) {
				return type;
			}
		}
		throw new IllegalArgumentException("Invalid LogicalOperator name: " + operator);
	}
}
